/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.just.dusin.ooii.component.standard;

import java.util.List;
import java.util.Properties;
import org.just.dusin.ooii.component.Sink;
import org.dusin.webcoal.exception.OOIIException;
import org.just.dusin.ooii.util.CipherUtil;

/**
 *
 * @author Administrator
 */
public class MD5CheckPipe implements Sink{
    
    Sink sink;

    @Override
    public void process(String msgWithMD5) throws OOIIException {
        String md5= msgWithMD5.substring(msgWithMD5.length()-32);
        String msg = msgWithMD5.substring(0,msgWithMD5.length()-32);
        if(CipherUtil.validatePassword(md5,msg)){          //不能通过MD5验证的消息将丢弃
            sink.process(msg);
        }else{
            System.out.println("not valid with md5");
        }
        
    }

    @Override
    public void process(List<String> msgs) throws OOIIException {
       for(String msg:msgs){
           process(msg);
       }
    }

    @Override
    public void initComponent(Properties props) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void destroyComponent() throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Sink getSink() {
        return sink;
    }

    public void setSink(Sink sink) {
        this.sink = sink;
    }
    
}
